/**
 * 
 */
package datamodel.tree.linked;

import datamodel.rucksack.Rucksack;
import datamodel.tree.TreeNode;

/**
 * An implementation of the TreeNode interface for a linked tree.
 * 
 * @author Kevin Munk, Jakob Karolus
 * @version 1.0
 * 
 */
public class LinkedTreeNode extends TreeNode {
	private LinkedTreeNode left = null,
						   right = null,
						   parent = null;
	
	/**
	 * constructor
	 * 
	 * @param rucksack the rucksack to set
	 */
	public LinkedTreeNode(Rucksack rucksack) {
		super(rucksack);
	}
	
	/**
	 * Sets the left child of the LinkedTreeNode.
	 * @param tn The new child.
	 */
	public void setLeftChild(LinkedTreeNode tn) {
		left = tn;
	}
	
	/**
	 * Sets the right child of the LinkedTreeNode.
	 * @param tn The new child.
	 */
	public void setRightChild(LinkedTreeNode tn) {
		right = tn;
	}
	
	/**
	 * Sets the parent node of the LinkedTreeNode.
	 * @param tn The parent node
	 */
	public void setParent(LinkedTreeNode tn) {
		parent = tn;
	}
	
	
	/**
	 * Returns the left child.	
	 * @return The left child
	 */
	public LinkedTreeNode getLeftChild() {
		return left;
	}
	
	/**
	 * Returns the right child.
	 * @return The right child
	 */
	public LinkedTreeNode getRightChild() {
		return right;
	}
	
	/**
	 * Checks if node possesses a parent node.
	 * @return True if parent node exists.
	 */
	public boolean hasParent() {
		return (parent != null);
	}
	
	/**
	 * Returns the parent node.
	 * @return The parent node
	 */
	public LinkedTreeNode getParent() {
		return parent;
	}
	
	/**
	 * Checks if left child exists.
	 * @return True if left child exists.
	 */
	public boolean hasLeftChild() {
		return (left != null);
	}
	
	/**
	 * Checks if right child exists.
	 * @return True if right child exists.
	 */
	public boolean hasRightChild() {
		return (right != null);
	}
	


}
